//
//  FPRecordPointModel.m
//  FinanceProject
//
//  Created by 陈显摆 on 2025/4/23.
//

#import "FPRecordPointModel.h"

@implementation FPRecordPointModel


+ (void)recordPointWithChannel:(NSString *)channel success:(void (^)(NSInteger, NSString * _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    NSMutableDictionary *param = APIClient.creatAPIDictionary;
    
    [param setObject:channel forKey:@"channel"];
    
    [[APIClient sharedInstance] requestWithURLString:[MAIN_URL stringByAppendingString:RECORD_POINT_CHANNEL_URL] parameters:param type:HttpRequestTypePost success:^(id responseObject, NSString *msg, NSInteger code) {
        
        NSError *error;
        
        id object = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:&error];
        
        NSInteger httpCode = [[object objectForKey:@"code"] integerValue];
        
        NSString *message = [object objectForKey:@"msg"];
        
        if (success) {
            
            success(httpCode , message);
        }
        
    } failure:^(NSError *error) {
        
        if (failure) {
            failure(error);
        }
    }];
}


+ (void)recordPointWithType:(NSString *)type success:(void (^)(NSInteger, NSString * _Nonnull))success failure:(void (^)(NSError * _Nonnull))failure {
    
    NSMutableDictionary *param = APIClient.creatAPIDictionary;
    
    [param setObject:type forKey:@"type"];
    
    [[APIClient sharedInstance] requestWithURLString:[MAIN_URL stringByAppendingString:RECORD_POINT_COUNT_URL] parameters:param type:HttpRequestTypePost success:^(id responseObject, NSString *msg, NSInteger code) {
        
        NSError *error;
        
        id object = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:&error];
        
        NSInteger httpCode = [[object objectForKey:@"code"] integerValue];
        
        NSString *message = [object objectForKey:@"msg"];
        
        if (success) {
            
            success(httpCode , message);
        }
        
    } failure:^(NSError *error) {
        
        if (failure) {
            failure(error);
        }
    }];
}


@end
